package Game;

public abstract class UnitEffect extends Effect {
	// ATTRIBUTES
	
	boolean activeDirectly = false;
	
	// METHODS
	
	public UnitEffect(String _name, String _desc, boolean _activeDirectly) {
		super(_name, _desc);
		activeDirectly = _activeDirectly;
	}
	
	public UnitEffect(String _name, String _desc, int[] actives) {
		super(_name, _desc, actives);
	}
	
	public boolean isConditionMet(Unit unit) {
		return true;
	}
	
	@Override
	public void onObtain(Unit unit) {
		super.onObtain(unit);
		if (activeDirectly || isConditionMet(unit))
			onActivate(unit);
	}
	
	@Override
	public void onDismiss(Unit unit) {
		if (activeDirectly || isConditionMet(unit))
			onDeactivate(unit);
		super.onDismiss(unit);
	}
	
	public abstract void onActivate(Unit unit);
	
	public abstract void onDeactivate(Unit unit);
	
	@Override
	public String toString() {
		String s = "";
		
		s += name + "\n";
		s += desc;
		
		return s;
	}
}
